/*
 * @LastEditors: yuSeen
 * @LastEditTime: 2021-11-19 21:58:14
 * 天凉好个秋
 */

import { createHash } from "crypto"

// 将对象中所有可转为number型的字符串转为number
export const objToInt = (params: object) => {
    if(typeof params !== 'object') return params
    for(let [key, value] of Object.entries(params)) {
        if(!isNaN(value)) params[key] = Number(value)
    }
    return params
}

/**
 * @description: md5加密
 * @param {string} password
 * @return {string} md5 password
 */
export const encryptPassword = (password: string): string => {
    return createHash('md5').update(password).digest('hex')
}